package com.bayss.web.controller;

import com.bayss.core.constant.ResultMsg;
import com.bayss.core.service.deliveryman.DeliverymanService;
import com.bayss.web.uresponse.DeliverymanResponse;
import com.bayss.web.verify.ParamVerify;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 骑手操作
 *
 * @author yangjian
 */
@Slf4j
@RestController
public class DeliverymanController extends ApiBaseController{

    private final DeliverymanService deliverymanService;

    @Autowired
    public DeliverymanController(DeliverymanService deliverymanService) {
        this.deliverymanService = deliverymanService;
    }

    /**
     * 骑手登录
     */
    @RequestMapping(value = "/deliveryman/login.json")
    public ResultMsg login(@ParamVerify(isNotBlank = true)String account,
                           @ParamVerify(isNotNull = true)String password,
                           String addrName) {
        return ResultMsg.success(deliverymanService.login(account, password, addrName));
    }

    /**
     * 骑手登出
     */
    @RequestMapping(value = "/deliveryman/outlogin.json")
    public ResultMsg login(DeliverymanResponse deliverymanResponse,
                           String addrName) {
        return ResultMsg.success(deliverymanService.outlogin(deliverymanResponse.getDeliId(), addrName));
    }


}
